import * as config from '../config';
import Vue from 'vue';

export function getList(params) {
  return Vue.http.get(config.config.lesson.list, params);
};

export function getDetail(params) {
  return Vue.http.get(config.config.lesson.detail, params);
};

export function addFav(params) {
  return Vue.http.get(config.config.lesson.addFav, params);
};

export function yuyue(params) {
  return Vue.http.get(config.config.lesson.yuyue, params);
};

export function getMyLessons(params) {
  return Vue.http.get(config.config.lesson.myLessons, params);
}

export function getDays() {
  let now = new Date();
  var monthArr = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
  // let month = now.toString().split(' ')[1];
  let month = monthArr[now.getMonth()];
  let count = config.config.lesson.count;
  // 从现在往后取7天
  let dateArr = [];
  for (let i = 0; i < count; i++) {
    let newD = new Date();
    newD.setDate(newD.getDate() + i);
    dateArr.push(newD);
  }
  return {
    'month': month,
    'days': dateArr
  };
};
